﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RLRT.Common;
using RLRT.Models;

namespace RLRT.Web
{
    public partial class InventoryQuery : LocalPage
    {
        /// <summary>
        /// 页面加载
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                #region 验证权限

                #endregion

                #region 获取参数

                #endregion

                //初始化
                this.Initialize();
            }

            #region 页面标题

            this.Title = PageTitle.Text;

            #endregion

            #region 页面要素


            #endregion
        }

        #region 初始化

        /// <summary>
        /// 初始化
        /// </summary>
        private void Initialize()
        {
            #region 页面内容
            using (RTProvider rtProvider = new RTProvider())
            {
                var whs = rtProvider.GetWarehouseList();
                LocalGlobal.BindListItems(WhCode, whs.DefaultView, "wmdes", "wmwhs", true);
            }

            this.WhCode.SelectedIndex = -1;
            this.PoNo.Text = string.Empty;
            this.PoName.Text = string.Empty;
            #endregion

            //绑定列表
            //this.BindList();
        }

        #endregion

        #region 绑定数据

        /// <summary>
        /// 绑定列表
        /// </summary>
        private void BindList()
        {
            using (RTProvider rtProvider = new RTProvider())
            {
                List.DataSource = rtProvider.GetInventoryList(this.PoNo.Text.Trim(), this.PoName.Text.Trim(), this.WhCode.SelectedValue.Trim());
            }
            List.DataBind();
        }

        /// <summary>
        /// 翻页
        /// </summary>
        protected void List_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            List.PageIndex = e.NewPageIndex;
            this.BindList();
        }

        #endregion

        #region 操作

        /// <summary>
        /// 确定
        /// </summary>
        protected void OKButton_Click(object sender, EventArgs e)
        {
            this.BindList();
        }

        /// <summary>
        /// 取消
        /// </summary>
        protected void CancelButton_Click(object sender, EventArgs e)
        {
            this.Initialize();
        }

        #endregion

    }
}